package h0731;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 整数对最小和
 * @date 2024/7/31 23:08
 */
public class MinSumInteger2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int[] a = new int[n1];
        for (int i = 0; i < n1; i++) {
            a[i] = sc.nextInt();
        }
        int n2 = sc.nextInt();
        int[] b = new int[n2];
        for (int i = 0; i < n2; i++) {
            b[i] = sc.nextInt();
        }
        //要求的对数
        int m = sc.nextInt();
        System.out.println(findMinSumOfPairs(a, b, m));
    }

    private static int findMinSumOfPairs(int[] array1, int[] array2, int k) {
        //定义最小堆
        PriorityQueue<int[]> minHeap = new PriorityQueue<>((o1, o2) -> Integer.compare(o1[0] + o1[1], o2[0] + o2[1]));

        for (int i = 0; i < array1.length; i++) {
            minHeap.offer(new int[]{array1[i],array2[0],0});
        }
        int sum=0;
        for (int i = 0; i < k; i++) {
            int[] current= minHeap.poll();
            sum+=current[0]+current[1];
            int nextIndex=current[2]+1;
            if (nextIndex< array2.length){
                minHeap.offer(new int[]{current[0],array2[nextIndex],nextIndex});
            }
        }
        return sum;
    }
}
